
// 视频播放页面上需要的一个混入。

export default {
	data() {
		return {
			current: 0,
			durationField: 'duration',
			// 视频 时长 ，秒级单位
			videoDownTime: 0,
			videoDuration: 0,
			rotateDeg: 0,
			lotteryVisible: true,
			lotteryDrawingVisible: false,
			videoList: [],
			videoContext: null,
			activeRedEnvelopeInfo: {},
			redEnvelopeList: []
			
		}
	},
	mounted(){
		const vm = this
		if (vm.$refs.lotteryPopup) {
			console.log('vm.$refs.lotteryPopup', vm.$refs.lotteryPopup.$el)
		}
		
		
	},
	methods: {
		startPlay() {
			
		},
		closeLottery() {
			this.lotteryVisible = false
			if (this.current < this.videoList.length - 1) {
				// 有则自动翻到下一个视频
				this.change({
					detail: {
						current: this.current + 1
					}
				})
			}
		},
		openLotteryDrawing() {
			console.log("abc")
			this.lotteryVisible = false
			this.lotteryDrawingVisible = true
		},
		closeLotteryDrawing() {
			this.lotteryVisible = false
			this.lotteryDrawingVisible = false
			
			if (this.current < this.videoList.length - 1) {
				// 有则自动翻到下一个视频
				this.change({
					detail: {
						current: this.current + 1
					}
				})
			}
			console.log("这里有进来没有")
		},
		
		/**
		 * 进度条发生变化时做的一个事。理论上来说，只需要这一个事件就行，其内部甚至都不需要倒计时。
		 * @param {Object} item
		 * @param {Object} $event
		 */
		timeupdateHandler(item, $event) {
			const eventDetails = $event?.detail || {}
			const duration = eventDetails.duration
			const currentTime = eventDetails.currentTime
			if (duration && currentTime) {
				this.videoDuration = duration
				this.videoDownTime = $event.detail.duration - $event.detail.currentTime
			}
		}
	}
}